<?php
require_once "../lib/function.php";
if($_POST)
{
    $data["userID"]=addslashes(strip_tags(trim($_POST['userID'])));
    $data["userPwd"]=addslashes(strip_tags(trim($_POST["userPwd"])));
    $code=strtolower($_POST['code']);
    session_start();
    if($code == strtolower($_SESSION["verify"]))
    {
        $sql="select * from admininfo where userID=? and userPwd=?";
        require_once "../lib/MySQLDB.class.php";
        $db=MySQLDB::getInstance();
        $res=$db->fetchRow($sql,"ss",$data);
        if($res)
        {
            $_SESSION["userID"]=$res["userID"];
            $_SESSION["userName"]=$res["userName"];
            layerAlert("登录成功！", 1, "index.php");
        }else {
            layerAlert("账号或密码错误！", 2, "login.php");
        }
    }else{
        layerAlert("验证码错误！",2,"login.php");
    }
}else if(isset($_GET["logout"]) && $_GET['logout']=='true'){
    session_start();
    @session_destroy();
    layerAlert("退出成功！",1,'login.php');
}else{
    require_once "view/login.html";
}
